import $http from '../../../servers/http';
import { Result } from 'seats/schema/Result';

const BASE_URL = '/weathersms/web/targeted';

/**模板列表*/
export const getTargetTemplateList = (data: any): Promise<Result<any>> => {
  return $http.get({
    url: `${BASE_URL}/smsTemplateShow/list`,
    data,
  });
};

/** 电子围栏 */
export const erpFenceApi = {
  create: (data: any): Promise<Result<any>> =>
    $http.post({
      url: `${BASE_URL}/smsfence/save`,
      data,
    }),
  read: (id: string): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smsfence/info/${id}`,
    }),
  delete: (id: string): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smsfence/delete?id=${id}`,
    }),
  list: (data: any): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smsfence/list`,
      data,
    }),
  // gridList: (data: any): Promise<Result<any>> =>
  //   $http.get({
  //     url: `${BASE_URL}/smsfence/baseFence/list`,
  //     data,
  //   }),
  county: (): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/sysarea/getArea`,
    }),
};

/**短信任务*/
export const targetSmsApi = {
  /**查询当前用户能否切换短信模板*/
  judgeTargetCanEdit: (): Promise<Result<any>> => {
    return $http.get({
      url: `/weathersms/sys/user/yingji`,
    });
  },
  create: (data: any): Promise<Result<any>> =>
    $http.post({
      url: `${BASE_URL}/smsmessage/normalTaskSave`,
      data,
    }),
  read: (id: string): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smsmessage/info/${id}`,
    }),
  delete: (data: any): Promise<Result<any>> =>
    $http.post({
      url: `${BASE_URL}/smsmessage/delete`,
      data,
    }),
  list: (data: any): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smsmessage/list`,
      data,
    }),
  portrait: (data: any): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smsfencestaticmodel/messageLabelList`,
      data,
    }),
};

/**白名单任务*/
export const whiteListApi = {
  create: (data: any): Promise<Result<any>> =>
    $http.post({
      url: `${BASE_URL}/smswhitemain/save`,
      data,
    }),
  read: (id: string): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smswhitemain/info/${id}`,
    }),
  delete: (data: any): Promise<Result<any>> =>
    $http.post({
      url: `${BASE_URL}/smswhitemain/delete`,
      data,
    }),
  list: (data: any): Promise<Result<any>> =>
    $http.get({
      url: `${BASE_URL}/smswhitemain/list`,
      data,
    }),
  stop: (data: any): Promise<Result<any>> =>
    $http.post({
      url: `${BASE_URL}/smswhitemain/stopTask`,
      data,
    }),
};
